package com.zmc.third.controller;


import com.zmc.common.utils.PageUtils;
import com.zmc.common.utils.R;
import com.zmc.third.infrastructure.bean.query.PaySettingQuery;
import com.zmc.third.infrastructure.entity.PaySettingEntity;
import com.zmc.third.infrastructure.service.PaySettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * @Author：zmc
 * @Date：2024/11/8 21:01
 * 支付配置
 */

@RestController
@RequestMapping("/pay/setting")
public class PaySettingController {

    @Autowired
    private PaySettingService paySettingService;

    /**
     * 列表
     */
    @PostMapping("/list")
    public R list(@RequestBody PaySettingQuery query){
        PageUtils page = paySettingService.queryPage(query);
        return R.page(page);
    }


    /**
     * 信息
     */
    @PostMapping("/info")
    public R info(@RequestBody PaySettingEntity paySettingEntity){
        return R.ok(paySettingService.getById(paySettingEntity.getId()));
    }

    /**
     * 保存
     */
    @PostMapping("/add")
    public R save(@RequestBody PaySettingEntity paySettingEntity){
        paySettingEntity.setPayType(1);
        paySettingEntity.setSignType("RSA2");
        paySettingService.save(paySettingEntity);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody PaySettingEntity paySettingEntity){
        paySettingService.updateById(paySettingEntity);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody PaySettingEntity paySettingEntity){
        paySettingService.removeById(paySettingEntity.getId());
        return R.ok();
    }

}
